﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PyroGen;
using System.IO;


namespace PyroGenTest
{
    [TestClass]
    public class IncludeExplorerTest
    {

        [TestMethod]
        public void IncludeExplorerGetSnippets()
        {/*

            string name = "foobar__.cs";
            string content = "aaaabcbaabaabcaaba";

            if(!File.Exists(name))
                File.Create(name).Close();


            StreamWriter fs = new StreamWriter(name);

            fs.Write(content);
            fs.Close();



            Dictionary<string, Tuple<CodeType, Terminator>> dict = new Dictionary<string, Tuple<CodeType, Terminator>>();
            List<Snippet> slist = IncludeExplorer.GetSnippets(name, dict);


            File.Delete(name);

            Assert.AreEqual(1, slist.Count);
            Assert.AreEqual<Snippet>(new Snippet(content, CodeType.Text), slist[0]);*/
        }



        [TestMethod]
        public void IncludeExplorerExpandSimple()
        {
            /*

            string nameSrc = "source__.cs";
            string contentSrc = "aaaabc<include=embeded_.cs>aaba";

            string nameEmb = "embeded_.cs";
            string contentEmb = "xoxxxxxox";


            if (!File.Exists(nameSrc))
                File.Create(nameSrc).Close();

            if (!File.Exists(nameEmb))
                File.Create(nameEmb).Close();

            StreamWriter fs = new StreamWriter(nameSrc);
            fs.Write(contentSrc);
            fs.Close();


            fs = new StreamWriter(nameEmb);
            fs.Write(contentEmb);
            fs.Close();




            Dictionary<string, Tuple<CodeType, Terminator>> dict = new Dictionary<string, Tuple<CodeType, Terminator>>();
            dict.Add("<", new Tuple<CodeType, Terminator>(CodeType.ConfigCode, Terminator.Start));
            dict.Add(">", new Tuple<CodeType, Terminator>(CodeType.ConfigCode, Terminator.End));

            List<Snippet> slist = IncludeExplorer.GetSnippets(nameSrc, dict);
            List<Snippet> fslist = IncludeExplorer.ExpandIncludesOnce(slist, dict);

            File.Delete(nameSrc);
            File.Delete(nameEmb);

            Assert.AreEqual(3, fslist.Count);
            Assert.AreEqual(new Snippet("aaaabc", CodeType.Text), fslist[0]);
            Assert.AreEqual(new Snippet(contentEmb, CodeType.Text), fslist[1]);
            //Assert.AreEqual(new Snippet("
            */
          //  Assert.AreEqual<Snippet>(new Snippet(content, CodeType.Text), slist[0]);
        }
        

    }
}
